#!/usr/bin/python
# -*- coding:utf-8 -*-
#插入排序
#@author: wklken@yeah.net


def insert_sort(l):
    print l
    for i in range(1,len(l)):
        print "index[",i,"]=",l[i]
        value = l[i]
        while i >= 1 and l[i-1] > value:
            l[i] = l[i-1]
            i -= 1
        l[i] = value
        print l
    print l    
l = [8, 4, 3, 7, 6, 5, 2, 1]
insert_sort(l)  
